Chris Pollett >Old Classes >
CS151

( Print View )

Student Corner:
  [Grades Sec5]

  [Submit Sec5]

  [Email List Sec5]

  [
Lecture Notes]

Course Info:
  [Texts & Links]
  [Topics]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]

Practice Exams:
  [Mid1]  [Mid2]  [Final]

                           












CS151 Fall 2005Practice Midterm 2

To study for the midterm I would suggest you: (1) Know how to do (by heart) all the practice problems. (2) Go over your notes three times. Second and third time try to see how huch you can remember from the first time. (3) Go over the homework problems. (4) Try to create your own problems similar to the ones I have given and solve them. (5) Skim the relevant sections from the book. (6) If you want to study in groups, at this point you are ready to quiz each other. The practice midterm is below. Here are some facts about the actual midterm: (a) The midterm will be in class Nov 9. (b) It is closed book, closed notes. Nothing will be permitted on your desk except your pen (pencil) and test. (c) You should bring photo ID. (d) There will be more than one version of the test. Each version will be of comparable difficulty. (e) If your cell-phone or beeper goes off you will be excused from the test at that point and graded on what you have done till your excusal. (f) One problem (less typos) on the actual test will be from the practice test.

[Student Generated Solutions-PDF]

1. Explain how the subtyping relationship works for arrays in Java. Distinguish between the terms overloading and overriding.

2. Explain how name collision when multiple interfaces are implemented is handled in Java.

3. Let swap(arr,i,j) be a method which swaps the elements at index i and index j in array arr. Define what the term design by contract means and give a good contract for this method in the format we used in class for preconditions and postconditions.

4. What does it mean to be in the canonical form for Java classes as described in the book?

5. Describe and give the UML diagram for the Singleton pattern. Give an example of how to do refactoring by delegation.

6. What is abstract coupling? What is the iterator design pattern? How is this pattern an example of abstract coupling?

7. Give an example of the Factory Design pattern that you used in your Hw3 solution.

8. Define the term framework. Give a Java code fragment using generics to create a LinkedList of int's, insert the numbers 1, 2,3 into it, and then iterate over the elements in this list, printing them out. Indicate where autoboxing/unboxing is being done.

9. Explain how to create a JFrame, add a JButton to it, show the frame. The button should have a listener so that when it is clicked the text on the button changes.

10. Briefly describe and give uses for the State pattern.